<?php
/**
 * Created by PhpStorm.
 * User: xiangfeng
 * Date: 2022/4/20
 * Time: 3:39 PM
 */

namespace app\api\service;


use think\Service;
use WeMini\Message;

class WeminiService extends Service
{
    private static $tmplids = TMPLIDS_ARR;

    /**
     * @return array
     */
    public static function getTmplIds(): array
    {
        $data = [];
        foreach (self::$tmplids as $val) {
            $data[] = $val['value'];
        }
        return $data;
    }

    /**
     * 消息发送-订阅消息
     * @param array $param
     * @return array
     * @throws \WeChat\Exceptions\InvalidResponseException
     * @throws \WeChat\Exceptions\LocalCacheException
     */
    public static function sendMsg(array $param)
    {
        $message = Message::instance(['appid' => APP_KEY, 'appsecret' => APP_SECRET]);
        $result = $message->subscribeSend($param);
        return $result;
    }
}